#include <QDebug>
#include <QDBusMessage>
#include <QDBusArgument>

#include "dbus-monitor.h"

#define DBUSVAR

bool DBusMonitor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection) {
    QVariantList args = message.arguments();
    QString name = args[0].toString(), icon = args[2].toString(),
            summary = args[3].toString(), body = args[4].toString();
    QStringList actions = args[5].toStringList();
    const QDBusArgument hints = args[6].value<QDBusArgument>();
    uint rid = args[1].toUInt(); int etime = args[7].toInt();
    qDebug() << QString("name:%1, icon:%2, summary:%3, body:%4, rid:%5, etime:%6").
                        arg(name).arg(icon).arg(summary).arg(body).arg(rid).arg(etime);

    qDebug() << "actions:" << actions;
    //qDebug() << "hints:";
    hints.beginMap();
    while(!hints.atEnd()) {
        QString hkey;
#if !defined(DBUSVAR)
        QVariant hvalue;
#else
        QDBusVariant hvalue;
#endif
        hints.beginMapEntry();
        hints >> hkey >> hvalue;
        hints.endMapEntry();
        qDebug() << "hkey:" << hkey << ", hvalue:" <<
#if !defined(DBUSVAR)
        hvalue;
#else
        hvalue.variant();
#endif
    }
    hints.endMap();
    return true;
    return true;
}


QString DBusMonitor::introspect(const QString &path) const {
    qDebug() << "path:" << path;
    return "";
}
